#ifndef VISUALOBJECT_H
#define VISUALOBJECT_H

#include "abstractgameobject.h"

class ImageData
{
public:
	ImageData() {}
	ImageData(const QString& path, const QImage& image)
		: m_path(path)
		, m_image(image)
	{}

	const QString& imagePath() const
	{
		return m_path;
	}

	const QImage& image() const
	{
		return m_image;
	}

	bool operator==(const ImageData& rhs)
	{
		return (m_path == rhs.m_path && m_image == rhs.m_image);
	}

	bool operator!=(const ImageData& rhs)
	{
		return (m_path != rhs.m_path || m_image != rhs.m_image);
	}
private:
	QString m_path;
	QImage m_image;
};

class VisualObject : public AbstractGameObject
{
	Q_OBJECT
    friend class Document;
public:
	typedef QList<QRect> Frames;

	const Frames& frames() const;

    bool isAnimation() const;
    bool hasPhysics();

	GameObjectType type() const;

	void setImageData(const ImageData& imageData);
	const ImageData& imageData() const;

	void setHorizontalPattern(int value);
	int horizontalPattern() const;

	void setNumFrames(int value);
	int numFrames() const;

	void setAnimationSpeed(float speed);
	float animationSpeed() const;

	void setLoop(bool bLoop);
	bool isLoop() const;

	void generateAnimation();
private:
    VisualObject(QObject* parent, const QString& name);
    ImageData m_imageData;
    Frames m_frames;
	QPointer<AbstractGameObject> m_physicsObject;

	int m_nHorizontalPattern;
	int m_nNumFrames;
	float m_fSpeed;
	bool m_bLoop;
};

#endif // VISUALOBJECT_H
